﻿using System;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using Common.Extensions;

namespace Common.Modules
{
    public static class Security
    {
        public static string CreateHashedPassword(string value, string salt)
        {
            string hashedPassword = value.CreateHash();
            string saltedPassword = string.Concat(hashedPassword, salt);
            return saltedPassword.CreateHash();
        }

        public static string CreateSalt()
        {
            RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();
            byte[] buff = new byte[64];
            rng.GetBytes(buff);
            return Convert.ToBase64String(buff);
        }
    }
}